package com.ruoyi.order.api.factory;

import com.ruoyi.order.api.RemoteOrderService;
import com.ruoyi.order.api.domain.Evaluation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

@Slf4j
@Component
public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderService> {
    @Override
    public RemoteOrderService create(Throwable cause) {
        log.error("评分模块调用失败，请检查~");
        return new RemoteOrderService() {
            @Override
            public List<Evaluation> avgStatistics() {
                return Collections.emptyList();
            }
        };
    }
}
